import { createRouter, createWebHashHistory } from 'vue-router'

// 路由规则
const routes = [
  {
    path: '/',
    component() {
      return import('@/views/Layout.vue')
    },
    children: [
      {
        path: '/',
        component() {
          return import('@/views/home')
        },
      },
      {
        path: '/category/:id',
        component() {
          return import('@/views/category')
        },
      },
      {
        path: '/category/sub/:id',
        component() {
          return import('@/views/category/sub.vue')
        },
      }
    ]
  }
]

// 创建路由实例
const router = createRouter({
  // 使用hash的路由模式
  history: createWebHashHistory(),
  routes
})

export default router
